#include "keyboard.hpp"
#include "system.hpp"
#include "pic.hpp"
#include "interrupts.hpp"
#include "vga.hpp"
#include "cpuexceptions.hpp"

namespace{
    const byte keyboard_irq = 1;
}

keyboard_handler::keyboard_handler(){
    system::set_irq_handler(keyboard_irq,isr);
}

keyboard_handler::~keyboard_handler(){
    system::unset_irq_handler(keyboard_irq,isr);
}


void keyboard_handler::isr(){
    while(!(system::inportb(0x64) & 1)); //Wait until the byte is ready (necessary on some older machines...)
    byte scancode = system::inportb(0x60);
    if (scancode == 0x01) system::interrupt(123);
    //...
    system::pic_end_of_interrupt(keyboard_irq);
}

